<?php
class AJD_Database 
{
	var $name;
	var $_dbhost;
	var $_dbusername;
	var $_dbpassword;
	var $_dbname;
	var $_link;

    function getName()
    {
        return $this->name;
    }

	function singleselect($sql)
	{
		$this->connect();
		$res = mysql_query($sql,$this->_link);
		$row = mysql_fetch_assoc($res);
		mysql_free_result($res);
		return $row;
	}
	
	function connect()
	{
		$link = mysql_connect(
			$this->_dbhost,
			$this->_dbusername,
			$this->_dbpassword
		);
		if (!$link) {
			die('Could not connect: '.mysql_error());
		}
		mysql_select_db($this->_dbname,$link) or die('Could not select database');
		$this->_link = $link;
	}

    function __construct($name,$dbhost,$dbusername,$dbpassword,$dbname)
    {
        if ($name && $dbhost && $dbusername && $dbpassword && $dbname) {
        	$this->name = $name;
            $this->_dbhost = $dbhost;
            $this->_dbusername = $dbusername;
            $this->_dbpassword = $dbpassword;
            $this->_dbname = $dbname;
        }
        else
        {

        }
    }

    function __destruct()
    {
        $this->cleanUp();
    }

    function cleanUp()
    {
        return true;
    }

}
?>